package com.example.demo.pojo;

import cn.hutool.core.date.DateTime;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.DateSerializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.shiro.io.Serializer;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import javax.persistence.Id;
import java.time.LocalDateTime;
import java.util.Date;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
 * <p>
 *
 * </p>
 *
 * @author Chas
 DatasourceInstance
 Tue Aug 15 17:37:05 CST 2023
 * @since 2023-08-15
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Document("b_user_tenant")
@ApiModel(value = "UserTenant对象", description = "用户与租户关系表")
public class UserTenantDo {

    @ApiModelProperty("用户与租户关系唯一主键")
    @Id
    private String id;

    @ApiModelProperty("登录帐号(默认采用手机号码)")
    @Field("login_name")
    private String loginName;

    @ApiModelProperty("租户ID")
    @Field("tenant_id")
    private String tenantId;

    @ApiModelProperty("0删除；1启用;对应的租户中的用户状态被修改则也更新该表")
    @Field("status")
    private Integer status;

    @ApiModelProperty("创建时间")
    @Field("create_time")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @CreatedDate
    private LocalDateTime createTime;

    @ApiModelProperty("更新时间")
    @Field("update_time")
    @LastModifiedDate
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    @ApiModelProperty("1表示该用户时总公司/代理商/租户的账号,该账号默认有用户平台的全部权限")
    @Field("admin_status")
    private Integer adminStatus;
}